function e(e) {
    return e && e.__esModule ? e : {
        default: e
    };
}

function t(e) {
    Object.keys(e).forEach(function(t) {
        e[t].forEach(function(e) {
            e.verName = (0, n.getName)(e.version), e.expireDate = e.expiretime.split(" ")[0].replace(/-/g, ".");
            var t = e.expiretime.replace(/-/g, "/");
            e.isexpire = new Date().getTime() - new Date(t).getTime() > 0;
        });
    });
}

var i = e(require("../../utils/api2")), a = e(require("../../utils/util")), n = require("../../utils/plans"), s = require("../../public/pages/signin-page/checkIfNeedSignin");

Page({
    data: {
        createList: [],
        manageList: [],
        isLoading: !0
    },
    onLoad: function() {
        var e = this;
        this.loadSiteList().then(function(t) {
            e.setData({
                isLoading: !1
            }), 0 === t.create.length && 0 === t.manager.length && e.loadDefaultTplList();
        }), this.$addListener("list.refresh", function() {
            return e.loadSiteList();
        });
    },
    onShow: function() {
        a.default.updateViewSiteStatus();
    },
    onPullDownRefresh: function() {
        this.loadSiteList().then(wx.stopPullDownRefresh);
    },
    create: function() {
        var e = this;
        if (!(0, s.askForSignin)()) {
            var t = {
                from: 2
            };
            a.default.collectSiteCreatData({
                node: "create",
                params: t
            }).then(function(t) {
                var i = t.stepid;
                e.$route("/pages/site-create/index/index?mode=create&stepid=" + i);
            });
        }
    },
    loadSiteList: function() {
        var e = this;
        return i.default.site.manager.lists({
            data: {
                isqywx: 0
            },
            desc: "数据加载"
        }).then(function(i) {
            return t(i), e.setData({
                createList: i.create,
                manageList: i.manager
            }), i;
        });
    },
    loadDefaultTplList: function() {
        var e = this;
        i.default.site.template.gettpllistsbyversion({
            data: {
                version: 3
            }
        }).then(function(t) {
            e.setData({
                tpllist: t.lists
            });
        });
    }
});